using System;

public partial class LoginPage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void LoginForm_Authenticate(object sender, System.Web.UI.WebControls.AuthenticateEventArgs e)
    {
        UserSmall.userDataTable userTable = new UserSmall.userDataTable();
        UserSmallTableAdapters.userTableAdapter userDA = new UserSmallTableAdapters.userTableAdapter();
        userDA.Fill(userTable, this.LoginForm.UserName, this.LoginForm.Password);
        if (userTable.Rows.Count > 0)
        {
            User user = new User();
            user.Id = userTable[0].id;
            user.Name = userTable[0].name;
            user.Password = userTable[0].password;
            user.RoleId = userTable[0].role_id;
            Session[UserManager.SessionName] = user;
            string pageLink = Request.QueryString["ref"];
            if (pageLink != null&&pageLink!=string.Empty)
            {
                LoginForm.DestinationPageUrl = pageLink + ".aspx";
            }

            e.Authenticated = true;
        }
        else
        {
            e.Authenticated = false;
        }
    }
}
